package tg.app.aqplan;

import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.mbo.StatefulMbo;
import psdi.mbo.StatusHandler;
import psdi.util.MXException;

/***
 * 
 * @author pzx
 * 
 */
public class Aqplmx extends StatefulMbo implements AqplmxRemote {

	private static final long serialVersionUID = 1L;

	public Aqplmx(MboSet ms) throws MXException, RemoteException {
		super(ms);
	}

	public void add() throws MXException, RemoteException {
		super.add();
		setValue("num", (int) getThisMboSet().max("num") + 1, 11L);
		MboRemote owner = getOwner();
		if(owner!=null){
			setValue("AQPLANID", owner.getString("AQPLANID"), 11L);
			setValue("SITEID", owner.getString("SITEID"));
			setValue("ORGID", owner.getString("ORGID"));
		}

	}

	@Override
	protected StatusHandler getStatusHandler() {
		return new AqplmxStatusHandler(this);
	}

	@Override
	protected MboSetRemote getStatusHistory() throws MXException,
			RemoteException {
		return getMboSet("AQPLMXSTATUS");
	}

	@Override
	public String getStatusListName() {
		return "AQPLMXSTATUS";
	}

}
